#include <bits/stdc++.h>

#define eb emplace_back
#define fi first
#define se second
#define in read<int>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)

using namespace std;

using ll = long long;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const ll INF = 123456789123456789;
const int N = 1e5 + 10;

int n, m, son[N], fa[N], dep[N], top[N], siz[N], ind[N], tim, dfn[N];
ll tdep[N];
veg G[N];

void dfs(int x, int p) {
	fa[x] = p; siz[x] = 1; dep[x] = dep[p] + 1;
	for(auto y : G[x]) if(y.fi ^ p) tdep[y.fi] = tdep[x] + y.se, dfs(y.fi, x), siz[x] += siz[y.fi], (siz[y.fi] > siz[son[x]]) && (son[x] = y.fi); 
}

void dfs1(int x, int anc) {
	ind[dfn[x] = ++tim] = x; top[x] = anc; if(son[x]) dfs1(son[x], anc);
	for(auto y : G[x]) if(y.fi ^ fa[x] && y.fi ^ son[x]) dfs1(y.fi, y.fi);
}

namespace seg {
	struct line {
		ll k, b;
		line(ll _k = 0, ll _b = INF): k(_k), b(_b) {}
		ll operator [](ll x) { return k * tdep[ind[x]] + b; }
	} val[N << 1];
	ll mn[N << 1];
	int ch[N << 1][2], L[N << 1], R[N << 1], md[N << 1], ndn, rt;
	void build(int &o, int l = 1, int r = n) {
		o = ++ndn; L[o] = l; R[o] = r; mn[o] = INF; md[o] = l + r >> 1; if(l == r) return;
		build(ch[o][0], l, md[o]); build(ch[o][1], md[o] + 1, r);
	}
	void tins(int o, line v) {
		chkmin(mn[o], v[L[o]]); chkmin(mn[o], v[R[o]]); chkmin(mn[o], v[md[o]]);
		if(val[o][md[o]] > v[md[o]]) swap(v, val[o]); if(L[o] == R[o]) return;
		if(v[L[o]] < val[o][L[o]]) tins(ch[o][0], v), chkmin(mn[o], mn[ch[o][0]]);
		if(v[R[o]] < val[o][R[o]]) tins(ch[o][1], v), chkmin(mn[o], mn[ch[o][1]]);
	}
	int xl, xr;
	void ins(int o, line v) {
		if(xl <= L[o] && R[o] <= xr) return tins(o, v), void();
		if(xl <= md[o]) ins(ch[o][0], v); if(xr > md[o]) ins(ch[o][1], v);
		chkmin(mn[o], min(mn[ch[o][0]], mn[ch[o][1]]));
	}
	ll query(int o) {
		if(xl <= L[o] && R[o] <= xr) return mn[o];
		ll ans = INF; if(xl <= md[o]) chkmin(ans, query(ch[o][0])); if(xr > md[o]) chkmin(ans, query(ch[o][1]));
		chkmin(ans, val[o][max(L[o], xl)]); chkmin(ans, val[o][min(R[o], xr)]);
		return ans;
	}
	void upd(int l, int r, line v) { xl = l; xr = r; ins(rt, v); }
	ll query(int l, int r) { xl = l; xr = r; return query(rt); }
}

using seg :: line;

int LCA(int x, int y) {
	while(top[x] ^ top[y]) {
		if(dep[top[x]] < dep[top[y]]) swap(x, y);
		x = fa[top[x]];
	} return dep[x] < dep[y] ? x : y;
}

ll dis(int x, int y) { return tdep[x] + tdep[y] - 2 * tdep[LCA(x, y)]; }

void tmodify(int l, int r, ll st, ll ed) {
	ll k = ed == st ? 0 : (ed - st) / (tdep[ind[r]] - tdep[ind[l]]);
	ll b = st - k * tdep[ind[l]]; seg :: upd(l, r, line(k, b));
}

void modify(int x, int y, ll a, ll b) {
	int st = x;
	while(top[x] ^ top[y]) {
		if(dep[top[x]] < dep[top[y]]) swap(x, y);
		tmodify(dfn[top[x]], dfn[x], a * dis(st, top[x]) + b, a * dis(st, x) + b);
		x = fa[top[x]];
	} if(dfn[x] > dfn[y]) swap(x, y); tmodify(dfn[x], dfn[y], a * dis(st, x) + b, a * dis(st, y) + b);
}

ll query(int x, int y) {
	ll ans = INF;
	while(top[x] ^ top[y]) {
		if(dep[top[x]] < dep[top[y]]) swap(x, y);
		chkmin(ans, seg :: query(dfn[top[x]], dfn[x]));
		x = fa[top[x]];
	} if(dfn[x] > dfn[y]) swap(x, y); chkmin(ans, seg :: query(dfn[x], dfn[y]));
	return ans;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in, m = in;
	rep(i, 2, n) { int u = in, v = in, w = in; G[u].eb(v, w); G[v].eb(u, w); }
	dfs(1, 0); dfs1(1, 1); seg :: build(seg :: rt);
	while(m--) {
		int op = in, s = in, t = in, a, b;
		if(op == 1) a = in, b = in, modify(s, t, a, b);
		else printf("%lld\n", query(s, t));
	}
	return 0;
}
